package com.neuedu.controller;

import com.neuedu.service.Assistant;
import com.neuedu.service.InterViewService;
import com.neuedu.service.MinioService;
import com.neuedu.service.impl.AiServiceCommonImpl;
import com.neuedu.vo.AiVo;
import com.neuedu.vo.ResultJson;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.service.AiServices;
import dev.langchain4j.store.memory.chat.ChatMemoryStore;
import io.minio.errors.*;
import jakarta.annotation.Resource;
import org.apache.http.util.ByteArrayBuffer;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Map;

@RestController
@RequestMapping("/ai")
public class AiController {
    @Resource
    InterViewService interViewService;

    @PostMapping("/start")
    ResultJson<AiVo> start (String sessionId, Long login_id, String message) {
        return ResultJson.success(interViewService.answer(sessionId, login_id, message));
    }
    @PostMapping("/send")
    ResultJson<String> send (String sessionId, Long login_id, @RequestParam MultipartFile file) throws IOException, ServerException, InsufficientDataException, ErrorResponseException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        return ResultJson.success(interViewService.getVoice(login_id, file, sessionId));
    }
    @PostMapping("/end")
    ResultJson<Boolean> end (String sessionId, Long login_id) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        return ResultJson.success(interViewService.end(sessionId, login_id));
    }
}
